package verfify;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created by zhaopeng on 2/14/17.
 */
public class VerifyReducer extends Reducer<Text, IntWritable, Text, Text> {

    private Text value = new Text();
    @Override
    public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int coveredNum = 0, unCoverNum = 0;
        for (IntWritable tmp : values) {
            if (tmp.get() == 0)
                unCoverNum++;
            else if (tmp.get() == 1)
                coveredNum++;
        }
        String result = coveredNum + "," + unCoverNum;
        value.set(result);
        context.write(key, value);
    }
}
